<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./index.js"></script>
</head>
<body>
    <button>发起请求</button>
    <h2></h2>
    <script>
        const btn = document.querySelector('button')
        const text = document.querySelector('h2')
        
        btn.addEventListener('click',  function(){
           Promise.all([myAjax({method: 'GET', url: 'http://ajax-base-api-t.itheima.net/api/getbooks1'}),
          myAjax({method: 'POST',data : {bookname: '家',author : '巴金', publisher : '杭州出版社'},url : 'http://ajax-base-api-t.itheima.net/api/addbook'})]).then( res => {
            text.innerHTML = '这是首页'
        }).catch(req => {
            text.innerHTML = `${req}`
        })
           

        //   const res = await myAjax({method: 'GET', url: 'http://ajax-base-api-t.itheima.net/api/getbooks'})
        //   console.log(res);
        })
    </script>
</body>
</html>